package com.jack.vipmis.vip.wei.service;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;

import com.jack.vipmis.common.entity.search.SearchOperator;
import com.jack.vipmis.common.entity.search.Searchable;
import com.jack.vipmis.common.service.BaseService;
import com.jack.vipmis.vip.wei.entity.WeiReplyEntity;
import com.jack.vipmis.vip.wei.repository.WeiReplyEntityRepository;

/**
 * 
 * @author JackLiang
 * @version 1.0
 * @date 2014-8-27
 */
@Service
public class WeiReplyEntityService extends BaseService<WeiReplyEntity, Long> {
	private static final int	PAGE_SIZE	= 10;

	private WeiReplyEntityRepository getWeiReplyEntityRepository() {
		return (WeiReplyEntityRepository) baseRepository;
	}

	/**
	 * 
	 * @param page
	 * @param id
	 * @return
	 */
	public Page<WeiReplyEntity> list(int page, long id) {
		Searchable searchable = Searchable.newSearchable();
		searchable.addSearchFilter("weiId", SearchOperator.eq, id);
		searchable.setPage((page - 1), PAGE_SIZE);
		searchable.addSort(Direction.DESC, "replyTime");

		return getWeiReplyEntityRepository().findAll(searchable);
	}
}
